package class8;


import cn.hutool.core.lang.tree.TreeUtil;
import common.TreeNode;
import common.TreeNodeUtils;

import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;

public class TestDemo {

    public static void main(String[] args) {
        TreeNode root = TreeNodeUtils.getTreeNode();
        preOrder(root);

    }

    private static void preOrder(TreeNode root) {
        if (root == null) return;
        TreeNode[] stack = new TreeNode[50];
        int r = 0;
        stack[r++] = root;
        while (r > 0) {
            TreeNode cur = stack[--r];
            System.out.print(cur.val + "\t");
            if (cur.right != null) {
                stack[r++] = cur.right;
            }
            if (cur.left != null) {
                stack[r++] = cur.right;
            }
        }
    }

}
